<?php
require_once $GLOBALS['ROO'] . 'Modules/Geo/class.geo.php';
//================ FORMS ===================
$MDRC = 'ED';
$MDAC = 'ED';
$MD1 = '';
if (isset($_POST['RID']) && $_POST['RID'] > 0) {
    $OBJCTRC = $_POST['RID'];
}

if (!isset($OBJCTRC)) {
    $MDRC = 'ED';
    $MDAC = 'ED';
    $VWRCDT = 1;
    $GET[0] = 1;
    $OBJCTRC = 0;
    $RCVARS = $GLOBALS['MYT']->db_array("DESCRIBE beneficiarios");
    for ($v = 1; $v <= $RCVARS[0]; $v++) {
        $RCVAR = $RCVARS[$v]['Field'];
        $GET[1][$RCVAR] = '';
    }
    $GETREL[1]['uniRelation'] = 0;
} else {
    $MDRC = 'RD';
    $MD1 = '" disabled readonly="';
    if (isset($_GET['MDRCED'])) {
        $MDRC = 'ED';
        $MD1 = '';
    }
    $GET = $GLOBALS['MYT']->db_array("SELECT * FROM beneficiarios WHERE BnfNumero = $OBJCTRC");
    $GETREL = $GLOBALS['MYT']->db_array("SELECT uniRelation FROM unionclientesbeneficiarios WHERE uniBeneficiario = {$OBJCTRC} AND uniCliente = {$_POST['CID']}");
}
if (!isset($GET[1])) {
    die("Error:00030");
}
$ReceiverGeo = New Geo();
$ReceiverCountries = Country::getActiveCountries();
mn_field('hidden', 'ED', 'MDRC', $MDRC, '', '', '', '');
?>
<div class="View">
    <div id="RCMSG"></div>
    <div class="ViewTitle">Dados do Beneficiario</div>
    <div class="ViewActions" NOWRAP><?php
if ($MDRC == 'RD') {
    mn_field('button', 'ED', 'MDRCED', 'Modificar', '12', '12', '', 'SUBMIT" onClick="
	document.ReceiverProperties.action=\'_response/call.php?get=Operative/view/viewreceiver&MDRCED=ED\';
	subform(\'ReceiverProperties\',\'NWRC\');');
} ?> | Bloqueio: <?php mn_field('hselect', 'ED', 'BnfBloqueado', $GET[1]['BnfBloqueado'], "Desbloqueado;Bloqueado#0;1", '', '', '"
				onchange="document.ReceiverProperties.action=\'_response/call.php?get=Operative/receiverblock\';
				subform(\'ReceiverProperties\',\'RCMSG\');'); ?>
    | Tipo de Pessoa: <?php mn_field('hselect', 'ED', 'BnfNumExt', $GET[1]['BnfNumExt'], "Fisica;Juridica#0;1", '', '', ''); ?>
    | Parentesco: <?php mn_field('select', 'ED', 'uniRelation', $GETREL[1]['uniRelation'], "SELECT stpAreaID AS ID, stpName AS NAME FROM hf_systypes WHERE stpGroup = 3 AND stpFlag = 2", ' ', '', $MD1 . ''); ?></div>
    <div style="float: right"><?php mn_field('button', 'ED', 'opv_RCV_leave', ' X (Fechar) ', '12', '12', '', 'SUBMIT" onClick="document.getElementById(\'NWRC\').innerHTML=\'\';'); ?></div>
    <div style="clear: both; width: 100%; background-color: #E5E5E5">
        <table width="100%" border="0" cellpadding="3" cellspacing="2">
            <tr>
                <td bgcolor="#F5F5F5">Nome</td>
                <td><?php mn_field('text', 'ED', 'BnfNombre', $GET[1]['BnfNombre'], '100', '50', 'True', $MD1 . ''); ?>
                <td bgcolor="#F5F5F5">Obs:</td>
                <td><?php mn_field('text', 'ED', 'BnfNotes', $GET[1]['BnfNotes'], '50', '50', '', $MD1 . ''); ?></td>
                <td bgcolor="#F5F5F5">Telefone</td>
                <td><?php mn_field('text', 'ED', 'BnfTelefono', $GET[1]['BnfTelefono'], '18', '12', 'True', $MD1 . ''); ?></td>

            </tr>
            <tr>
                <td bgcolor="#F5F5F5">Morada</td>
                <td><?php mn_field('text', 'ED', 'BnfDireccion', $GET[1]['BnfDireccion'], '50', '50', '', $MD1 . ''); ?></td>
                <td bgcolor="#F5F5F5">Bairro</td>
                <td><?php mn_field('text', 'ED', 'BnfBarrio', $GET[1]['BnfBarrio'], '45', '28', 'True', $MD1 . ''); ?></td>
                <td bgcolor="#F5F5F5">Telefone</td>
                <td><?php mn_field('text', 'ED', 'BnfTelefono2', $GET[1]['BnfTelefono2'], '18', '12', 'True', $MD1 . ''); ?></td>
            </tr>
        </table>

        <table width="100%" border="0" cellspacing="2" cellpadding="3">
            <tr>
                <td>País</td>
                <td>Estado/Província</td>
                <td>Cidade</td>
                <td>Documento</td>
            </tr>
            <tr bgcolor="#F5F5F5">
                <td width="15%"><?php echo $ReceiverGeo->GetCountry($GET[1]['BnfPais'],'BnfPais','BnfProvincia','BnfCiudad',$ReceiverCountries,$GET[1]['BnfProvincia'],'GeoR','GeoC','
                    document.ReceiverProperties.action=\'_response/call.php?get=Operative/view/viewreceiverdocument\';
                    subform(\'ReceiverProperties\',\'DocVal\');','ED'); ?></td>
                <td width="20%"><div id="GeoR"><?php echo $ReceiverGeo->GetRegion($GET[1]['BnfProvincia'], 'BnfProvincia', 'BnfCiudad', $GET[1]['BnfPais'], 0, 'GeoC', 'ED'); ?></div></td>
                <td width="25%"><div id="GeoC"><?php echo $ReceiverGeo->GetCity($GET[1]['BnfCiudad'], 'BnfCiudad', $GET[1]['BnfProvincia'], $GET[1]['BnfPais'], 'ED'); ?></div></td>
                <td width="40%"><div id="DocVal"><?php if ($GET[1]['BnfPais'] != '') {
                        include('viewreceiverdocument.php');
                    } ?></div></td>
            </tr>
        </table>
        <div style="text-align: center"><?php
                    if ($MDRC == 'ED') {
                        mn_field('button', 'ED', 'PRSVRC', 'Guardar', '12', '12', '', 'SUBMIT" onClick="
	document.ReceiverProperties.action=\'_response/call.php?get=Operative/opv_receiveredit\';
	subform(\'ReceiverProperties\',\'RCMSG\');');
                    }
?></div>
    </div>
</div>